var app = angular.module('myApp');
app.controller('remenContro',['$scope','$http','$timeout','proServ',function($scope,$http,$timeout,proServ){
	$http.get("./json/guangchangremen.json").then(function (ob) {
		
		//点击图片放大
		$timeout(function(){
			var btn = document.querySelectorAll('.suoFang');
			for(var i=0;i<btn.length;i++){
				
				btn[i].onclick = showOrHidden;
			}
			var over = document.querySelector('#p_over');
			over.onclick =  showOrHidden;
		},1000)
		
		
		function showOrHidden(ev){
			$('.p_wrap').html('');
			var src = $(this).attr("src");
			$('<img />').attr('src',src).appendTo($('.p_wrap'));
                
			var over = document.querySelector('#p_over');
			over.style.display = over.style.display == 'none' ? 'block' : 'none';
			
			//获取到当前产生的事件对象
			var e = ev || event;
			e.preventDefault();
		}
		
//		var Arr = [];
		$scope.addPros = function(){
			var items = ob.data.data.feeds;
			for(var i=0;i<items.length;i++){
				var i = items[i];
//				Arr.push(i);
//				console.log(Arr)
				
			}
			console.log(this);
			var item = items[this.$index];
			proServ.addPro(item);
			$(this).parent().children('.public-img').attr('src','public/img/ic_album_nav_followed_pressed.png')
		}
    })
	
	
}])